package Command;

use Moose::Role;
use Data::Dumper;

requires 'do_command';

has 'config'=> ( is => 'ro' );

sub command {
    my $self = shift;
    my ($sender, $who, $where, $what) = @_;


    if ($what =~ /^!([a-z0-9]+)\s?(.*?)?$/) {
        my ($cmd, $desc) = ($1,$2);
        my $irc = $sender->get_heap();
        my $nick = ( split /!/, $who )[0];
        my $channel = $where->[0];
        $channel =~ s/#//;
        return $self->do_command($irc, $nick, $channel, $cmd, $desc);
    }
    else {
        return 0;
    }
}

1;

